//
//  CompanyListView.m
//  HNJYB
//
//  Created by panshen on 2017/10/25.
//  Copyright © 2017年 Mag1cPanda. All rights reserved.
//

#import "CompanyListView.h"

@implementation CompanyListView

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.frame = [UIScreen mainScreen].bounds;
        self.backgroundColor = RGBA(0, 0, 0, 0.4);
        LRViewBorderRadius(self, 3, 1, [UIColor clearColor]);
        
        
        CGFloat tabX = 20;
        CGFloat tabH = ScreenHeight - 64 - 49;
        CGFloat tabY = (ScreenHeight - tabH) / 2;
        CGFloat tabW = ScreenWidth - 40;
        
        table = [[UITableView alloc] initWithFrame:CGRectMake(tabX, tabY, tabW, tabH) style:UITableViewStylePlain];
        table.delegate = self;
        table.dataSource = self;
        //        table.backgroundColor = [UIColor colorWithHexString:@"e7f4fc"];
        table.estimatedRowHeight = UITableViewAutomaticDimension;
        LRViewBorderRadius(table, 3, 1, [UIColor clearColor]);
        [self addSubview:table];
        
        [table registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
    }
    return self;
}


-(void)blankTaped:(UITapGestureRecognizer *)tap
{
//    [self removeFromSuperview];
}

-(void)setDataArr:(NSArray *)dataArr
{
    _dataArr = dataArr;
    
    [table reloadData];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.textLabel.font = [UIFont systemFontOfSize:13];
    NSDictionary *dic = _dataArr[indexPath.row];
    cell.textLabel.text = dic[@"inscomname"];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.block) {
        NSLog(@"%@",_dataArr[indexPath.row]);
        self.block(_dataArr[indexPath.row]);
        [self removeFromSuperview];
    }
}

@end
